package com.zygh.policeasset.service;

import cn.hutool.core.date.DateUtil;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.zygh.policeasset.mapper.UploadFileMapper;
import com.zygh.policeasset.mapper.purchaseTenderMapper;
import com.zygh.policeasset.pojo.PurchaseTender;
import com.zygh.policeasset.pojo.UploadFile;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
/* loaded from: police-asset-2.0-0.0.1-SNAPSHOT.jar:BOOT-INF/classes/com/zygh/policeasset/service/PurchaseTenderService.class */
public class PurchaseTenderService {
    @Autowired
    purchaseTenderMapper purchaseTenderMapper;
    @Autowired
    UploadFileMapper uploadFileMapper;

    public PurchaseTender queryById(Integer id) {
        return this.purchaseTenderMapper.queryById(id);
    }

    public PageInfo queryAll(int pageNum, int pageSize, String type, Integer status) {
        PageHelper.startPage(pageNum, pageSize);
        return new PageInfo(this.purchaseTenderMapper.queryAll(type, status));
    }

    public int add(PurchaseTender purchaseTender) {
        int count = this.purchaseTenderMapper.add(purchaseTender);
        int projectId = purchaseTender.getId().intValue();
        List<UploadFile> uploadFileList = purchaseTender.getUploadFileList();
        for (int i = 0; i < uploadFileList.size(); i++) {
            uploadFileList.get(i).setProjectId(projectId);
            uploadFileList.get(i).setProjectName(purchaseTender.getPurchaseType());
            uploadFileList.get(i).setFileType(1);
            uploadFileList.get(i).setCreateDate(DateUtil.now());
            this.uploadFileMapper.add(uploadFileList.get(i));
        }
        return count;
    }

    public int update(PurchaseTender purchaseTender) {
        return this.purchaseTenderMapper.update(purchaseTender);
    }

    public int deleteById(Integer id) {
        return this.purchaseTenderMapper.deleteById(id);
    }

    public int updateByid(Integer id, Integer status) {
        return this.purchaseTenderMapper.updateByid(id, status);
    }
}